home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group93a.txt
/
000016_icon-group-sender _Wed Jan 13 17:26:28 1993.msg
< prev
next >
Wrap
Internet Message Format
|
1993-04-21
|
3KB
Received: by cheltenham.cs.arizona.edu; Thu, 14 Jan 1993 05:22:48 MST
Date: 13 Jan 93 17:26:28 GMT
From: mercury.hsi.com!mlfarm!cs.arizona.edu!icon-group@uunet.uu.net (Steve Wampler)
Subject: Re: Pattern matching in Icon?
Message-Id: <9301131726.AA18608@turing.cse.nau.edu>
Sender: icon-group-request@cs.arizona.edu
To: icon-group@cs.arizona.edu
Status: R
Errors-To: icon-group-errors@cs.arizona.edu
On Jan 13 at 5:01pm, Michael Sperber writes:
} I'll try to make myself even clearer than last time. Let's take
} the example again:
}
} case s of {
} syntax_tree("let", args) : ... # args is assigned to the arguments
} # field of s
} syntax_tree("apply", args) : ...
} }
}
} Here, I probably glitched a bit, and things would have to look a bit
} different syntactically. What I meant though, was that the case is
} not supposed to evaluate the syntax_trees. Instead it's supposed to
} look if a is a record of type syntax_tree, and, if so, execute the
} first case, if the first component is "let", binding args to the
} second component for the following statements. Admittedly, I didn't
} think as much about syntax as I should have, and more work would have
} to be done on it. However, I hope it's clear what I mean.
}
} Cheers :-> Chipsy
}
Ah, I think I fully understand. I think this would take quite a
bit of changes to Icon to work - consider that in Icon, 'syntax_tree'
is just a function call, the user could (in a perverse moment), do
syntax_tree := f
and the case statement suddenly changes. I think the problem could
be resolved in specific instances, but it would greatly complicate the
case statement:
(if this function is a record constructor, then don't evaluate it,
it's a pattern...)
but I don't see how to do it in general. I think you would have
to restrict case clauses to *only* literals and patterns, which is
more restrictive than now (not that it would likely impact many people).
In the present form, you can still do it by
building your own set of pattern-matching operations (since the
runtime system has to have something to do it anyway):
case s of {
match_syntax_tree("let",s) : ...
match_syntax_tree("apply",s) :...
which would require you (as the programmer) to establish the pattern-matching
rules - though to me that's a net win, since I might want to do some form
of pattern matching that the language implementor didn't anticipate (such
as some form of 'symantic' pattern matching).
--
Steve Wampler
{....!arizona!naucse!sbw}
{sbw@turing.cse.nau.edu}